﻿@{
    ViewBag.Title = "Index";
}
<script>
    function setLocation(lat,lng,zo) {
        var mapOptions = {
            center: new google.maps.LatLng(lat,lng),
            zoom: zo,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(lat, lng),
            map: map,
            title: "Hello World!"
        });
    }

    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        } else {
            alert("Geolocation is not supported by this browser.");
        }
    }
    function showPosition(position) {
        var lat = position.coords.latitude;
        var lng = position.coords.longitude;
        setLocation(lat, lng,20);
        document.getElementById("id_longitude").value = lng;
    }
</script>
<style type="text/css">
      #map-canvas { height: 400px;width:800px; }
 </style>
<div id="map-canvas"></div>
<div style=""><a id="click_location" onclick="getLocation()">get location</a></div>
<div id="id_latitude"></div>
<div id="id_longitude"></div>


